{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-10-23T03:48:19.549490Z",
     "start_time": "2020-10-23T03:48:19.466611Z"
    }
   },
   "outputs": [],
   "source": [
    "from sklearn.model_selection import validation_curve\n",
    "from sklearn.datasets import load_digits\n",
    "from sklearn.svm import SVC\n",
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "\n",
    "digits=load_digits()\n",
    "X=digits.data\n",
    "y=digits.target"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-10-23T03:51:59.630851Z",
     "start_time": "2020-10-23T03:51:17.935348Z"
    }
   },
   "outputs": [],
   "source": [
    "param_range=np.logspace(-6,-2.3,5)\n",
    "train_loss,test_loss=validation_curve(SVC(),X,y,param_name='gamma',\n",
    "                                      param_range=param_range\n",
    "                                      ,cv=10,scoring='neg_mean_squared_error',\n",
    "                                            )\n",
    "train_loss_mean=-np.mean(train_loss,axis=1)\n",
    "test_loss_mean=-np.mean(test_loss,axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-10-23T03:51:59.762785Z",
     "start_time": "2020-10-23T03:51:59.635950Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x7f2c75c69700>]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD4CAYAAAD1jb0+AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/d3fzzAAAACXBIWXMAAAsTAAALEwEAmpwYAAAZKklEQVR4nO3df3DcdZ3H8dc7P0q7TSlNE5LYNglNFeEEK+SgtcLMXQVBRUTuZpTo4HljdOZA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9WeNpK2T7Svpa5Kui9+/TtJXZ7pvRejzGZJOl/QLSa3F7ucM9fliSRXx+1+dI5/zyWn7f0zSbcXuayH7G39+hYKlqvsk1RS7rzPwGX9B0qem255ijMDPk7TDObfTOXdU0n2SLs94zeWS/s0Ftkg6xcwaJtn3ckn3xO/fI+ndBe7HdBSkz8657c65381cN6alUH1+yDmXuErsFgVXgioVherzn9P2X6gsly4skkL9W5akr0v6tEqnrwmF7PO0FSPAs10MedkUX3Oifeucc/2SFL89NcI256tQfS5lM9HnDykY6ZSKgvXZzDrN7EVJbZL+KcI256Mg/TWzd0l6yTn326gbHIFC/r2+Jl5yuXOqJeBiBPhULoY80WumdCHlEkSfA5H12cw6JI1K6s6pdYVRsD475zqccysU9PeanFsYrcj7a2YxSR0qnV9SmQr1Gd8qqUXSakn9km6cSmOKEeBTuRjyRK850b574/9NUfx2X4Rtzleh+lzKCtZnM7ta0jsltbl4AbFEzMTnfK+kK/NuaTQK0d8WSadJ+q2Z7Ypv/42Z1Ufa8twV5DN2zu11zh13zo1J+raCcsvkivAlQIWknQo+pEQh/y8yXvMOjf8S4FeT7SvpBo3/EvNrM923me5z2r6/UOl9iVmoz/kSSc9Kqi12H2ewz69N2/9aSd8vdl9n4u91/HW7VFpfYhbqM25I2/8Tku6bUnuK9IfwdknPK/hGtiO+7aOSPhq/b5K+FX++Nz2csu0b375U0sOSXojfVhf7w56BPl+h4Lf6EUl7Jf2s2P2cgT7vUFBHfCr+UxJnZBS4zz+QtE3S05I2S1pW7H4Wsr8Z779LJRTgBfyMvxN/7dOSfqS0QD/RD1PpAcBTzMQEAE8R4ADgKQIcADxFgAOApwhwAPAUAQ4AniLAAcBT/w8+RPvND3QWtgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(param_range,train_loss_mean,'o-',color='r',label='Training')\n",
    "plt.plot(param_range,test_loss_mean,'o-',color='g',label='Cross')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
